{% extends "master.html" %}
{% block subtitle %} - 主面板 - 仓位管理 - 更新仓位{% endblock %}

{% block extJS %}
<script language="JavaScript" type="text/javascript">
//<![CDATA[
    function toSubmit(){
        var msg = [];
        clearMsg();
        $(".err").removeClass('err');
        
        if(!$("#name").val()){
            msg.push("请填写仓位名称！")
            $("#name").addClass("err");
        }
        
        if(msg.length > 0){
            alertError(msg);
            return false;
        }else{
            $("form").submit();
        }
    }
    
    function toCancel(){
        redirect_alert("{{MSG_LEAVE_WITHOUT_SAVING}}","{{url_for('bpIvt.view')}}")
    }  
//]]>
</script>
{% endblock %}

{% block main %}
<div class="container">
    <div class="row">
        <ol class="breadcrumb">
          <li><a href="{{url_for('bpRoot.view')}}">主面板</a></li>
          <li><a href="{{url_for('bpIvt.view')}}">仓位管理</a></li>
          <li class="active">更新仓位</li>
        </ol>
    </div>
    <div class="row">
        <div class="btn-toolbar pull-right">
            <div class="btn-group"><button onclick="toSubmit()"  class="btn btn-primary">确认提交</button></div>
            <div class="btn-group"><button onclick="toCancel()" class="btn btn-inverse">取消</button></div>
        </div>
    </div>
    <div class="row">
        <form class="form-horizontal" method='POST' action="{{url_for('bpIvt.view',action='update')}}">
        <fieldset>
            <legend>仓位详情</legend>
            <div class="col-md-6">
                <input type="hidden" name="id" value="{{obj.id}}"/>
                <div class="control-group">
                  <label class="control-label">仓库完整目录</label>
                  <div class="controls">
                      {{obj.fullPath}}
                  </div>
                </div>
 
                <div class="control-group">
                    <label class="control-label" for="parentID">上级仓库</label>
                    <div class="controls">
                        <select id="parentID" name="parentID">
                            {% for p in parents %}
                                {% if not (p.lft>=obj.lft and p.rgt<=obj.rgt) %}
                                {% if p.id==obj.parentID %}
                                    <option value="{{p.id}}" selected="selected">
                                        {{ (p.getLevel-1)*'&nbsp;&nbsp;&nbsp;&nbsp;'|safe }} {{p}}
                                    </option>
                                {% else %}
                                    <option value="{{p.id}}">
                                        {{ (p.getLevel-1)*'&nbsp;&nbsp;&nbsp;&nbsp;'|safe }} {{p}}
                                    </option>
                                {% endif %}
                                {% endif %}
                            {% endfor %}
                        </select>
                  </div>
                </div>
                
                <div class="control-group">
                  <label class="control-label" for="name">仓库名称<span style='color:red'>*</span></label>
                  <div class="controls">
                      <input type="text" name="name" id="name" value="{{obj.name}}"/>
                  </div>
                </div>
            </div>
            <div class="col-md-6"> 
                <div class="control-group">
                  <label class="control-label" for="address">仓库地址</label>
                  <div class="controls">
                      <textarea name="address" id="address">{{obj.address|f}}</textarea>
                  </div>
                </div>
                
                <div class="control-group">
                  <label class="control-label" for="remark">备注</label>
                  <div class="controls">
                      <textarea name="remark" id="remark">{{obj.remark|f}}</textarea>
                  </div>
                </div>         
                </div>
        </fieldset>
        </form>
    </div>
</div>
{% endblock %}